<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=0526b09fdae3df8480d2bb88fe17fbc4"></script>-->
<!--<script type="text/javascript" src="js/baidu.js?v=1.5&ak=0526b09fdae3df8480d2bb88fe17fbc4&services=&t=20130813025141"></script>-->
<!--<script type="text/javascript" src="baidu20130813025141.js/soucebaidu_20130813025141.js?v=1.5&ak=0526b09fdae3df8480d2bb88fe17fbc4&services=&t=20130813025141"></script>-->
<script type="text/javascript" src="baidu20130904.js/baidu.js?v=1.5&ak=0526b09fdae3df8480d2bb88fe17fbc4&services=&t=20130813025141"></script>
<script type="text/javascript" src="baidu20130904.js/map.js"></script>
<script type="text/javascript" src="baidu20130904.js/mapclick.js"></script>
<script type="text/javascript" src="baidu20130904.js/marker.js"></script>
<script type="text/javascript" src="baidu20130904.js/oppc.js"></script>
<script type="text/javascript" src="baidu20130904.js/scommon.js"></script>
<script type="text/javascript" src="baidu20130904.js/tile.js"></script>
<script type="text/javascript" src="baidu20130904.js/copyrightctrl.js"></script>
<script type="text/javascript" src="baidu20130904.js/navictrl.js"></script>
<!--<script type="text/javascript" src="js/maptile.js"></script>
<script type="text/javascript" src="js/mapclick.js"></script>
<script type="text/javascript" src="js/mapscommon.js"></script>
<script type="text/javascript" src="js/maplocal.js"></script>
<script type="text/javascript" src="js/mapoppc.js"></script>-->
<title>百度地图的Hello, World</title>
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
</style>

</head>

<!-- 
		百度api  http://developer.baidu.com/map/jshome.htm
		核心类 http://developer.baidu.com/map/reference/index.php?title=Class:%E6%80%BB%E7%B1%BB/%E6%A0%B8%E5%BF%83%E7%B1%BB
		地图实例 http://developer.baidu.com/map/jsdemo.htm	
 -->
<body>


</script>

<div id="allmap" style="width: 512px;height: 512px;position: absolute;left: 100px;top: 100px"></div>
</body>
<script type="text/javascript">
//创建惰性的一种方式
var getReq=(function(){
	var getReq;
	var xmlHttpRequest;
	if(typeof window.XMLHttpRequest ==="undefinded"){
		getReq=function(){
			xmlHttpRequest=new XMLHTTPRequest();
			return xmlHttpRequest;
		}
	}else if(typeof window.ActiveXObject){
		getReq=function(){
		 	xmlHttpRequest = new ActiveXObject('Microsoft.XMLHTTP');
		 	return xmlHttpRequest;
		 }
	}else{
		//应该不至于可以跑到这里吧
	}
	return getReq;
})();


var map = new BMap.Map("allmap");            
var point = new BMap.Point(116.404, 39.915); 
map.centerAndZoom(point,10);
//map.addControl(new BMap.NavigationControl());


function addMarker(){
	var bool=true;
	var marker
	/*marker1.addEventListener("mouseover",function(f){
		alert(f)
	alert("asdf");
	});*/
	return function(){
		if(bool){
			marker = new BMap.Marker(new BMap.Point(116.384, 39.925));  // 创建标注
			map.addOverlay(marker1); 
			bool=false;
		}else{
			map.cl
		}
	}
}
function enable(){
	var method=document.getElementById("mapMethod").value;
	//alert(typeof method);
	var params=document.getElementById("params").value;
	params=params.split(";");
	typeof map[method] == "function" && map[method].apply(map,params);

	//alert(typeof map[method]);
	/*if(typeof map[method] == "function") {
		//我就起了怪了，为什么第一个就是进不去呢？？结果也有，但是就是不能追进去
			//var result=map[method]();
			//alert(result.toString());
			map[method].apply(map);
		}
	*///var name="getBounds";
	//alert(typeof name);
	//map[name]();
	/*map.enableDragging();
	map.enableScrollWheelZoom();
	map.enableAutoResize();
	//map.setMapStyle({});
	alert(BMAP_API_VERSION);*/
	
}
function enable2(){
		var method=document.getElementById("mapMethod").value;
		eval(method);
	}
function addEvent(){
	map.addEventListener("click", function(){
 		alert("你点击了地图");
	});
}
function panBy(){
	 map.panTo(new BMap.Point(113.262232,23.154345)); 
}
function search(){
	var transit = new BMap.TransitRoute(map, {
  	renderOptions: {map: map}
	});
	transit.search("王府井", "西单");
}
</script>
<label>map对象函数</label>
<input type="text" id="mapMethod" placeholder="输入map对象函数名">
<input type="text" id="params" placeholder="输入参数，用;分割">
<input type="button" value="执行函数" onclick="enable();">
<input type="button" value="执行eval函数" onclick="enable2();"> 
<input type="button" value="触发" onclick="addEvent()">
<input type="button" value="添加marker点" onclick="addMarker();">
<input type="button" value="执行panBy" onclick="panBy();">
<input type="button" value="执行搜索" onclick="search();">

</html>

